package spring.superrun.record.mvc.service.impl;

import spring.superrun.record.mvc.entity.SuperrunLocations;
import spring.superrun.record.mvc.dao.SuperrunLocationsDao;
import spring.superrun.record.mvc.service.SuperrunLocationsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SuperrunLocations)表服务实现类
 *
 * @author makejava
 * @since 2021-06-16 16:05:04
 */
@Service("superrunLocationsService")
public class SuperrunLocationsServiceImpl implements SuperrunLocationsService {
    @Resource
    private SuperrunLocationsDao superrunLocationsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SuperrunLocations queryById(String id) {
        return this.superrunLocationsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<SuperrunLocations> queryAllByLimit(int offset, int limit) {
        return this.superrunLocationsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param superrunLocations 实例对象
     * @return 实例对象
     */
    @Override
    public SuperrunLocations insert(SuperrunLocations superrunLocations) {
        this.superrunLocationsDao.insert(superrunLocations);
        return superrunLocations;
    }

    /**
     * 修改数据
     *
     * @param superrunLocations 实例对象
     * @return 实例对象
     */
    @Override
    public SuperrunLocations update(SuperrunLocations superrunLocations) {
        this.superrunLocationsDao.update(superrunLocations);
        return this.queryById(superrunLocations.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.superrunLocationsDao.deleteById(id) > 0;
    }
}
